package com.it.day2;

/**
 * ClassName: T
 * Description: 类加载面试代码题
 *
 * @Author: csx
 * @Create: 2025/4/25 - 11:28
 * @version: v1.0
 */
public class T {
    public static int k = 0;
    public static T t1 = new T("t1");
    public static T t2 = new T("t2");
    public static int i = print("i");
    public static int n = 99;

    public int j = print("j");

    {
        print("构造块");
    }

    static {
        print("静态块");
    }

    public T(String str) {
        System.out.println((++k) + ":" + str + "  i=" + i + "  n=" + n);
        ++n;
        ++i;
    }

    public static int print(String str) {
        System.out.println((++k) + ":" + str + "  i=" + i + "  n=" + n);
        ++n;
        return ++i;
    }

    public static void main(String[] args) {
        Class clazz = T.class;
        ClassLoader classLoader = clazz.getClassLoader();

        ClassLoader classLoader1 = Thread.currentThread().getContextClassLoader();

        ClassLoader classLoader2 = ClassLoader.getSystemClassLoader();

        System.out.println(classLoader);
        System.out.println(classLoader1);
        System.out.println(classLoader2);
    }
}